package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/1/18
 * Time:18:17
 **/
public class FindOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书！");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入图书名字：");
        String name = scanner.nextLine();

        for (int i = 0; i < bookList.getSize(); i++) {
            Book book = bookList.getBooks(i);
            if(book.getName().equals(name)){
                System.out.println(book);
                return;
            }
        }
        System.out.println("未找到！");
    }
}
